package com.example.testapplication.retrofit;

import com.example.testapplication.bean.BaseResponse;
import com.google.gson.Gson;

import org.junit.Test;

import java.io.IOException;

import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;

public class WanAndroidUitText {
    Retrofit retrofit = new Retrofit.Builder().baseUrl("https://www.wanandroid.com/").build();
    WanAndroidService wanAndroidService = retrofit.create(WanAndroidService.class);

    @Test
    public void loginTest() throws IOException {
        Call<ResponseBody> call =
                wanAndroidService.login("lanceedu", "123123");
        Response<ResponseBody> response = call.execute();
        String result = response.body().string();
        System.out.println(result);
        // 手动进行数据转换
        BaseResponse baseResponse = new Gson().fromJson(result,BaseResponse.class);
        System.out.println(baseResponse);

    }
}
